package com.weikuang.fareast.http;


import android.text.TextUtils;

import com.lzy.okgo.model.HttpParams;
import com.weikuang.fareast.bean.CheckDetailBean;
import com.weikuang.fareast.bean.Count1Bean;
import com.weikuang.fareast.bean.CountBean;
import com.weikuang.fareast.bean.CountDetailBean;
import com.weikuang.fareast.bean.DailyCountBean;
import com.weikuang.fareast.bean.DeliveredOfficeBean;
import com.weikuang.fareast.bean.DeliveredOfficeDetailBean;
import com.weikuang.fareast.bean.DeliveredOrderBean;
import com.weikuang.fareast.bean.HotelBean;
import com.weikuang.fareast.bean.LoginNewBean;
import com.weikuang.fareast.bean.NoCheckHotelBean;
import com.weikuang.fareast.bean.NoCheckOrderBean;
import com.weikuang.fareast.bean.NoDeliverHotelBean;
import com.weikuang.fareast.bean.NoDeliverTeamBean;
import com.weikuang.fareast.bean.OfficeBean;
import com.weikuang.fareast.bean.OfficeReceivedBean;
import com.weikuang.fareast.bean.OfficeRequireBean;
import com.weikuang.fareast.bean.OperatorBean;
import com.weikuang.fareast.bean.QueryBean;
import com.weikuang.fareast.bean.QueryNewBean;
import com.weikuang.fareast.bean.ReceivedDetailBean;
import com.weikuang.fareast.bean.SimpleBean;
import com.weikuang.fareast.bean.TeamBean;
import com.weikuang.fareast.bean.TeamDeliverBean;
import com.weikuang.fareast.bean.UserBean;
import com.weikuang.fareast.bean.UsualGoodsBean;
import com.weikuang.fareast.utils.UserHelper;

import cn.dlc.commonlibrary.okgo.OkGoWrapper;
import io.reactivex.Observable;

/**
 * Created by Administrator on 2019/4/4.
 */

public class MainHttp {
    private final OkGoWrapper mOkGoWrapper;

    private MainHttp() {
        mOkGoWrapper = OkGoWrapper.instance();
    }

    private static class InstanceHolder {
        private static final MainHttp sInstance = new MainHttp();
    }

    public static MainHttp get() {
        return InstanceHolder.sInstance;
    }
    private String getToken() {
        return UserHelper.get().getToken();
    }

    /** 登录
     * @return
             */
    public Observable<LoginNewBean> userSignIn(String account, String password) {
        HttpParams params = new HttpParams();
        params.put("account", account);
        params.put("password", password);
        params.put("code", "washApp");
        params.put("uuid", "");
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"auth/login", params, LoginNewBean.class);
    }

    /**
     * 组别
     * @return
     */
    public Observable<TeamBean> getTeam(String hotel_id	) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"team", params, TeamBean.class);
    }

    /**
     * 科室
     * @return
     */
    public Observable<OfficeBean> getOffice(String hotel_id,String team_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        if (!TextUtils.isEmpty(team_id)) {
            params.put("team_id", team_id);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"office", params, OfficeBean.class);
    }
    /**
     * 医院
     * @return
     */
    public Observable<HotelBean> gethotel() {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"hotel", params, HotelBean.class);
    }
    /**
     * 医院
     * @return
     */
    public Observable<HotelBean> getGoods(String hotel_id, String office_id, String keyword) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(keyword)) {
            params.put("keyword",keyword);
        }
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }

        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"goods", params, HotelBean.class);
    }

    /**
     * 医院
     * @return
     */
    public Observable<HotelBean> gethotelNew(String keyword) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(keyword)) {
            params.put("keyword",keyword);
        }

        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"hotel", params, HotelBean.class);
    }

    /**
     * 查找分拣
     * @return
     */
    public Observable<CountBean> count2(String office_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"count2", params, CountBean.class);
    }
    /**
     * 必选产品
     * @return
     */
    public Observable<UsualGoodsBean> usualGoods(String office_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"usualGoods", params, UsualGoodsBean.class);
    }

    /**
     * 可选产品
     * @return
     */
    public Observable<UsualGoodsBean> selectGoods(String office_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"selectGoods", params, UsualGoodsBean.class);
    }

    /**
     * 统计提交
     * @return
     */
    public Observable<SimpleBean> countCommit(String office_id, String goods_id, String nums,String bads,String backs) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        params.put("bads", bads);
        params.put("backs", backs);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"countCommit", params, SimpleBean.class);
    }

    /**
     * 需求提交
     * @return
     */
    public Observable<SimpleBean> requireCommit(String office_id, String goods_id, String nums) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"requireCommit", params, SimpleBean.class);
    }

    /**
     * 科室需求
     * @return
     */
    public Observable<OfficeRequireBean> officeRequire(String office_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"officeRequire", params, OfficeRequireBean.class);
    }

    /**
     * 分发提交
     * @return
     */
    public Observable<SimpleBean> divideCommit(String office_id,String goods_id, String nums,String orderno) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        params.put("orderno", orderno);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"divideCommit", params, SimpleBean.class);
    }

    /**
     * 需求报废提交
     * @return
     */
    public Observable<SimpleBean> killCommit(String office_id, String goods_id, String nums) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("office_id", office_id);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"killCommit", params, SimpleBean.class);
    }



    /**
     * 医院送货单
     * @return
     */
    public Observable<DeliveredOrderBean> deliveredOrder() {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"deliveredOrder", params, DeliveredOrderBean.class);
    }

    /**
     * 送货单科室
     * @return
     */
    public Observable<DeliveredOfficeBean> deliveredOffice(String orderId) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"deliveredOffice", params, DeliveredOfficeBean.class);
    }

    /**
     * 科室送货明细
     * @return
     */
    public Observable<DeliveredOfficeDetailBean> deliveredDetail(String orderId) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"deliveredDetail", params, DeliveredOfficeDetailBean.class);
    }

    /**
     * 入库提交
     * @return
     */
    public Observable<SimpleBean> stockCommit( String orderId,String goods_id,String office_id, String nums) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        params.put("goods_id", goods_id);
        params.put("office_id", office_id);
        params.put("nums", nums);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"stockCommit", params, SimpleBean.class);
    }

    /**
     * 审核统计
     * @return
     */
    public Observable<DailyCountBean> dailyCount(String date) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(date)) {
            params.put("date", date);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"dailyCount", params, DailyCountBean.class);
    }

    /**
     * 未审核医院
     * @return
     */
    public Observable<NoCheckHotelBean> noCheckHotel() {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"noCheckHotel", params, NoCheckHotelBean.class);
    }

    /** 医院未审核订单
     * @return

     */
    public Observable<NoCheckOrderBean> noCheckOrder(String hotel_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("hotel_id", hotel_id);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"noCheckOrder", params, NoCheckOrderBean.class);
    }

    /** 审核详情
     * @return

     */
    public Observable<CheckDetailBean> checkDetail(String orderId) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"checkDetail", params, CheckDetailBean.class);
    }

    /** 审核提交
     * @return

     */
    public Observable<SimpleBean> checkCommit(String orderId,String goods_id,String nums,String bads,String backs) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        params.put("bads", bads);
        params.put("backs", backs);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"checkCommit", params, SimpleBean.class);
    }

    /** 审核修改
     * @return

     */
    public Observable<SimpleBean> checkEdit(String orderId,String goods_id,String nums,String checks,String bads,String backs,String hotel_id,String office_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        params.put("checks", checks);
        params.put("bads", bads);
        params.put("backs", backs);

        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"checkEdit", params, SimpleBean.class);
    }

    /** 审核作废
     * @return

     */
    public Observable<SimpleBean> checkKill(String orderId) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"checkKill", params, SimpleBean.class);
    }

    /** 未送货医院
     * @return

     */
    public Observable<NoDeliverHotelBean> noDeliverHotel() {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"noDeliverHotel", params, NoDeliverHotelBean.class);
    }

    /** 未送货分组
     * @return

     */
    public Observable<NoDeliverTeamBean> noDeliverTeam(String hotel_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("hotel_id", hotel_id);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"noDeliverTeam", params, NoDeliverTeamBean.class);
    }

    /** 未送货明细
     * @return
     */
    public Observable<TeamDeliverBean> teamDeliver(String team_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("team_id", team_id);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"teamDeliver", params, TeamDeliverBean.class);
    }

    /** 送货提交
     * @return
     */
    public Observable<SimpleBean> deliverCommit(String team_id,String goods_id,String nums,String bads,String orgs) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("team_id", team_id);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        params.put("bads", bads);
        params.put("orgs", orgs);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"deliverCommit", params, SimpleBean.class);
    }

    /** 查询
     * @return
     */
    public Observable<QueryBean> countQuery(String hotel_id,String team_id,String office_id, String begin, String end) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        if (!TextUtils.isEmpty(team_id)) {
            params.put("team_id", team_id);
        }
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }
        if (!TextUtils.isEmpty(begin)) {

            params.put("begin", begin);
        }
        if (!TextUtils.isEmpty(end)) {
            params.put("end", end);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"countQuery", params, QueryBean.class);
    }

    /** 审核查询
     * @return
     */
    public Observable<QueryNewBean> checkQuery(String hotel_id, String team_id, String office_id, String checkUser,String user_id, String date,String status) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        if (!TextUtils.isEmpty(team_id)) {
            params.put("team_id", team_id);
        }
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }
        if (!TextUtils.isEmpty(checkUser)) {
            params.put("checkUser", checkUser);
        }
        if (!TextUtils.isEmpty(user_id)) {
            params.put("user_id", user_id);
        }
        if (!TextUtils.isEmpty(status)) {
            params.put("status", status);
        }
        if (!TextUtils.isEmpty(date)) {
            params.put("date", date);
        }

        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"checkQuery", params, QueryNewBean.class);
    }

    /**审核人
     * @return
     */
    public Observable<OperatorBean> operator(String workType) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(workType)) {
            params.put("workType", workType);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"operator", params, OperatorBean.class);
    }


    /** 分拣科室订单
     * @return

     */
    public Observable<OfficeReceivedBean> officeReceived(String office_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"officeReceived", params, OfficeReceivedBean.class);
    }

    /** 分拣详情
     * @return

     */
    public Observable<ReceivedDetailBean> receivedDetail(String orderId) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);

        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"receivedDetail", params, ReceivedDetailBean.class);
    }

    /** 分拣提交
     * @return

     */
    public Observable<SimpleBean> receiveCheck(String orderId,String goods_id,String nums,String bads) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);

        params.put("goods_id", goods_id);
        params.put("nums", nums);
        params.put("bads", bads);

        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"receiveCheck", params, SimpleBean.class);
    }

    /** 人员
     * @return

     */
    public Observable<UserBean> user(String hotel_id, String office_id, String keyword,String workType) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        params.put("keyword", keyword);
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }
        params.put("keyword", keyword);

        if (!TextUtils.isEmpty(workType)) {
            params.put("workType", workType);
        }

        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"user", params, UserBean.class);
    }

    /** 统计列表
     * @return
     */
    public Observable<Count1Bean> count1(String hotel_id, String team_id, String office_id,  String begin,String end) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        if (!TextUtils.isEmpty(team_id)) {
            params.put("team_id", team_id);
        }
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }

        if (!TextUtils.isEmpty(begin)) {
            params.put("begin", begin);
        }
        if (!TextUtils.isEmpty(end)) {
            params.put("end", end);
        }

        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"count1", params, Count1Bean.class);
    }


    /** 统计明细
     * @return

     */
    public Observable<CountDetailBean> countDetail(String orderId) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"countDetail", params, CountDetailBean.class);
    }

    /** 统计修改
     * @return

     */
    public Observable<SimpleBean> countEdit(String orderId,String goods_id,String nums,String bads,String backs,String hotel_id,String office_id) {
        HttpParams params = new HttpParams();
        params.put("sign", getToken());
        params.put("orderId", orderId);
        params.put("goods_id", goods_id);
        params.put("nums", nums);
        params.put("bads", bads);
        params.put("backs", backs);
        if (!TextUtils.isEmpty(hotel_id)) {
            params.put("hotel_id", hotel_id);
        }
        if (!TextUtils.isEmpty(office_id)) {
            params.put("office_id", office_id);
        }
        return mOkGoWrapper.rxPostBean01(BaseUrls.BASRIMG1+"countEdit", params, SimpleBean.class);
    }


}
